package question

//1003. 检查替换后的词是否有效
func isValid_1003(s string) bool {
	//用栈，反向删除abc，最后栈为空就是真
	stack := make([]byte, 0)
	for i, _ := range s {
		stack = append(stack, s[i])
		if len(stack) >= 3 && string(stack[len(stack)-3:]) == "abc" {
			stack = stack[:len(stack)-3]
		}
	}
	return len(stack) == 0
}
